package com.ebase.core.page;

public class Sort {

    public static enum Order {
        ASC, DESC
    }

    protected String orders;

    public Sort() {

    }

    public Sort(String orders) {
        this.orders = orders;
    }

    public Sort(String property, Order order) {
        add(property, order);
    }

    public Sort add(String property, Order order) {
        if (orders == null)
            orders = property + " " + order.name().toLowerCase();
        else
            orders += "," + property + " " + order.name().toLowerCase();
        return this;
    }

    public String getOrderByClause() {
        String orderByClause = "";
        if ((orders != null) && (orders.trim().length() > 0)) {
            orderByClause = " order by " + orders;
        }
        return orderByClause;
    }

    public void setOrderByClause(String orderByClause) {

    }
}
